import type { AddressType } from "@/types/address"
import type { AddressItem } from "@/types/goods"
import { http } from "@/utils/request"

//添加收货地址
export const addAdress = (data: AddressType) => {
  return http({
    url: '/member/address',
    method: 'POST',
    data
  })
}

//获取收货地址列表
export const addressList = () => {
  return http<AddressItem[]>({
    url: '/member/address',
    method: 'GET'
  })
}

//获取收货地址详情
export const addressDetail = (id: string) => {
  return http<AddressItem>({
    url: `/member/address/${id}`,
    method: 'GET'
  })
}

//修改收货地址
export const addressUpdate = (id: string, data: AddressType) => {
  return http({
    url: `/member/address/${id}`,
    method: 'PUT',
    data
  })
}

//删除收货地址
export const deleteAddress = (id: string) => {
  return http({
    url: `/member/address/${id}`,
    method: 'DELETE'
  })
}